package com.oner365.test.jmx;
import com.sun.management.OperatingSystemMXBean;
import java.lang.management.ManagementFactory;

public class CpuUsage {
    private static OperatingSystemMXBean osMBean;
    
    static {
        osMBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
    }

    public static void main(String[] args) {
        double cpuUsage = osMBean.getProcessCpuLoad();
        System.out.println("CPU使用率：" + cpuUsage * 100 + "%");
    }
}
